package reflect;

import reflect.annotation.AutoRunClass;

import java.io.File;
import java.net.URISyntaxException;
import java.util.Arrays;

public class test3 {
    public static void main(String[] args) throws URISyntaxException, ClassNotFoundException {
        File dir = new File(
                test3.class.getResource(".").toURI()
        );
        File[] files = dir.listFiles(f -> f.getName().endsWith(".class"));
        String packageName = test3.class.getPackage().getName();
        for (File f:files){
            Class cls = Class.forName(packageName+"."+f.getName().substring(0,f.getName().indexOf(".")));
            if(cls.isAnnotationPresent(AutoRunClass.class)){
                System.out.println(cls.getSimpleName()+"被标注");
            }else{
                System.out.println(cls.getSimpleName()+"没有被标注");
            }
        }
    }
}
